<template>
  <a-table v-if="props.dataSource.length" :defaultExpandAllRows="props.isDefaultOpen === 0 ? false : true"
    :columns="props.columns" :data-source="props.dataSource" :row-key="(record: DataList, index: number) => record.id"
    @expand="onTableExpand" :row-selection="props.isSelect ? props.rowSelection : null">
  </a-table>
</template>
<script lang="ts" setup>
import { ref, watch } from 'vue';
import { treeProps } from './tableConfig/props';

const props = defineProps(treeProps);
// emit
const emits = defineEmits(["expanded", 'deleteRecord', 'changePage', 'moveRecord']);
//interface
interface DataList {
  [propName: string | number]: any;
}
//type
type tableextend = (a: Boolean, b: Object) => void;
//data
const onTableExpand: tableextend = (expanded, record: DataList) => {
  emits("expanded", expanded, record);
};
const selectedRowKeys = ref<(string | number)[]>([]);
const selfChecked = ref<Boolean>(false); //自定义全选按钮是否选中
//methods
// watch
watch(() => props.dataSource, (newVal, oldVal) => {
  if (newVal !== oldVal) {
    selectedRowKeys.value = [];
    selfChecked.value = false;
  }
})

</script>
